<?php

session_start();
ob_start();
include_once dirname(dirname(__FILE__)) . '/include/common.php';
$page = isset($_POST["page"]) ? intval($_POST["page"]) : 2;
$page = $page + 1;
$core = new core();
$load_more = 0;
$list_customer = $core->getListCustomer($page, $load_more, 25);
$html = '';

if ($list_customer) {
    foreach ($list_customer as $customer) {

        $html.=' <tr>
                    <td>' . $customer->name . '</td>
                    <td class="center">' . $customer->facebook_name . '</td>';
        if ($customer->facebook_link != "") {
            $html.='<td class="center"><a href="' . $customer->facebook_link . '">Lịnk facebook</a></td>';
        } else {
            $html.='<td class="center">Lịnk facebook</td>';
        }
        $html.='<td class="center">' . $customer->phone . '</td>                                
                    <td class="center">' . $customer->VIP . '</td>
                    <td class="center">';
        if ($_SESSION["user_role"] != 3) {
            $html.=' <a class="btn btn-info btn_edit_customer" href="addCustomer.php?id=' . $customer->customer_id . '" rel="">
                            <i class="icon-edit icon-white"></i>  
                            Edit                                            
                        </a>
                        <a href="javascript:void(0)" class="btn btn-danger btn_delete_customer" rel="' . $customer->customer_id . '">
                            <i class="icon-trash icon-white"></i> 
                            Delete
                        </a>';
        }
        $html.=' </td>
                </tr>';
    }
}
echo json_encode(array('type' => 0, 'html' => $html, 'page' => $page, 'load_more' => $load_more));
die;
?>